package cn.cvs.controller;

import cn.cvs.pojo.SysRole;
import cn.cvs.service.SysRoleService;
import cn.cvs.utils.TableVO;
import com.alibaba.fastjson.JSON;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/role")
public class RoleController {

    @Autowired
    private SysRoleService sysRoleService;

    @GetMapping("/list2")
    public String list2(){
        return "sysRole/list";
    }

    @GetMapping(value = "/list",produces = {"application/json;charset=utf-8"})
    @ResponseBody
    public String list(Integer page,Integer limit){

        List<SysRole> list = sysRoleService.list(page, limit);

        int count = sysRoleService.count();

        TableVO tableVO = new TableVO(0, count, list, "");

        String json = JSON.toJSONString(tableVO);

        return json;
    }



}
